package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.CategoryInfo;
import com.fx.entity.SysUser;
import com.fx.mapper.CategoryInfoMapper;
import com.fx.service.CategoryInfoService;
import com.fx.util.IdWorker;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class CategoryInfoServiceImpl implements CategoryInfoService {
    @Autowired
    private CategoryInfoMapper categoryInfoMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public CategoryInfo getById(String flId) {
        return categoryInfoMapper.getById(flId);
    }

    @Override
    public List<CategoryInfo> getList(Map<String, Object> map) {
        return categoryInfoMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return categoryInfoMapper.queryCount(map);
    }

    @Override
    public int save(CategoryInfo categoryInfo) {
        categoryInfo.setFlId(String.valueOf(idWorker.nextId()));
        categoryInfo.setFlCreatedTime(DateUtil.now());
        return categoryInfoMapper.save(categoryInfo);
    }

    @Override
    public int updateById(CategoryInfo categoryInfo) {
        return categoryInfoMapper.updateById(categoryInfo);
    }

    @Override
    public int remove(String flId) {
        return categoryInfoMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return categoryInfoMapper.batchRemove(flIds);
    }

    @Override
    public List<CategoryInfo> getCategoryByShop(String shopId) {
        return categoryInfoMapper.queryCategoryByShop(shopId);
    }

}
